
if exists(select name from sysobjects where name = 'sp_LoaiTinCreateEdit')
	drop proc sp_LoaiTinCreateEdit
go
/*
	Created by: Phuoc NH
	Created on: 13/05/2013 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_LoaiTinCreateEdit.sql
*/


-- =============================================
-- Author		: HP
-- Create date	: 2014-03-21
-- =============================================

CREATE PROCEDURE sp_LoaiTinCreateEdit
			
	@Id    		INT,
	@Ten            		NVARCHAR(200),
	@So_tin_hien_thi		TINYINT,
	@Nguoi_tao      		INT,
	@Ngay_tao       		VARCHAR(15),
	@Nguoi_sua      		INT,
	@Ngay_sua       		VARCHAR(15),
	@Status         		TINYINT
	
AS
BEGIN
    IF(@Id=0)
        BEGIN
        	INSERT INTO LoaiTin
        	(
		[Ten],
		[So_tin_hien_thi],
		[Nguoi_tao],
		[Ngay_tao],
		[Nguoi_sua],
		[Ngay_sua],
		[Status]
        	) 
        	VALUES 
        	(
		@Ten,
		@So_tin_hien_thi,
		@Nguoi_tao,
		@Ngay_tao,
		@Nguoi_sua,
		@Ngay_sua,
		@Status
        	)
        END
     ELSE
        BEGIN
            UPDATE LoaiTin     
            SET
		[Ten]             = @Ten,
		[So_tin_hien_thi] = @So_tin_hien_thi,
		[Nguoi_tao]       = @Nguoi_tao,
		[Ngay_tao]        = @Ngay_tao,
		[Nguoi_sua]       = @Nguoi_sua,
		[Ngay_sua]        = @Ngay_sua,
		[Status]          = @Status
	WHERE
		    [Loai_tin_id] = @Id;
        END
END
GO


